package com.mikao.controller.activity;

import com.mikao.dto.bo.DiscountForm;
import com.mikao.dto.bo.ReqDataTableDto;
import com.mikao.dto.vo.DiscountDto;
import com.mikao.dto.vo.RspDataTableDto;
import com.mikao.entity.Goods;
import com.mikao.service.DiscountService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author kenny
 */

@RestController
@RequestMapping("/management")
public class DiscountController {

    private DiscountService discountService;

    public DiscountController(DiscountService discountService) {
        this.discountService = discountService;
    }

    @GetMapping("/discountList")
    public RspDataTableDto<DiscountDto> discountList(ReqDataTableDto reqDataTableDto, String name) {
        return discountService.discountList(reqDataTableDto, name);
    }

    @PostMapping("/addDiscount")
    public void addDiscount(DiscountForm discountForm) {
        discountService.addDiscount(discountForm);
    }

    @PostMapping("/deleteDiscount/{id}")
    public void deleteDiscount(@PathVariable Long id) {
        discountService.deleteDiscount(id);
    }

    @GetMapping("/discount/goodsList")
    public List<Goods> goodsList(String q, String page) {
        return discountService.goodsList(q);
    }
}
